FROM golang:1.16-alpine
#FROM golang:1.16-alpine as builder

WORKDIR /go/src/example.com/demo

COPY ./ ./

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOARM=6 go build -ldflags '-w -s' -o app && chmod +x app

# This results in a single layer image
# 运行阶段
FROM scratch
# 从编译阶段的中拷贝编译结果到当前镜像中

COPY --from=0 /go/src/example.com/demo/app /
#COPY --from=builder /go/src/example.com/demo/server /
EXPOSE 8080

ENTRYPOINT ["/app"]